//
//  MineGalleryTableViewCell.swift
//  MT
//
//  Created by M on 2019/12/29.
//  Copyright © 2019 张强. All rights reserved.
//

import UIKit

@objc
protocol MineGalleryTableViewCellDelegate: NSObjectProtocol {
    @objc optional func galleryTableViewCell(_ cell: MineGalleryTableViewCell, didSelectGalleryCellWithType type: MineGalleryCollectionViewCell.Status, withIndexPath indexPath: IndexPath)
}

class MineGalleryTableViewCell: UITableViewCell {
    
    /// 代理
    weak var delegate: MineGalleryTableViewCellDelegate?
    
    var models: [UserMediaListModel]? {
        didSet {
//            collectionView.reloadData()
        }
    }
    
//    static var leftRightInset: CGFloat {
//        return 15
//    }
//
//    static var topBottomInset: CGFloat {
//        return 7
//    }
//
//    static var spacing: CGFloat {
//        return 4.0
//    }
//
//    static var count: CGFloat {
//        return 3.0
//    }
//
//    static var GalleryCollectionViewItemSize: CGSize {
//        let w = (ScreenWidth - (MineGalleryTableViewCell.leftRightInset * 2) - (MineGalleryTableViewCell.spacing * (MineGalleryTableViewCell.count - 1))) / MineGalleryTableViewCell.count
//        let h = 136.0 * w / 112.0
//        return CGSize(width: w, height: h)
//    }
//
//    static var GalleryCollectionViewHeight: CGFloat {
//        GalleryCollectionViewItemSize.height * count + ((count - 1) * spacing) + topBottomInset * 2
//    }
//
//    lazy var collectionView: UICollectionView = {
//
//        let flowLayout = UICollectionViewFlowLayout()
//        flowLayout.itemSize = CGSize(width: MineGalleryTableViewCell.GalleryCollectionViewItemSize.width, height: MineGalleryTableViewCell.GalleryCollectionViewItemSize.height)
//        flowLayout.minimumLineSpacing = MineGalleryTableViewCell.spacing
//        flowLayout.minimumInteritemSpacing = MineGalleryTableViewCell.spacing
//        let cv = UICollectionView(frame: self.contentView.bounds, collectionViewLayout: flowLayout)
//        cv.delegate = self
//        cv.dataSource = self
//        cv.backgroundColor = UIColor.theme.background
//        cv.contentInset = UIEdgeInsets(top: MineGalleryTableViewCell.topBottomInset,
//                                       left: MineGalleryTableViewCell.leftRightInset,
//                                       bottom: MineGalleryTableViewCell.topBottomInset,
//                                       right: MineGalleryTableViewCell.leftRightInset)
//        cv.showsHorizontalScrollIndicator = false
//        cv.showsVerticalScrollIndicator = false
//        cv.register(MineGalleryCollectionViewCell.self, forCellWithReuseIdentifier: String(describing: MineGalleryCollectionViewCell.self))
//        return cv
//    }()
    
    override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
        super.init(style: style, reuseIdentifier: reuseIdentifier)
        initializeUI()
    }
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
}

// MARK: ------------------------------------ Overrides ----------------------------------------
extension MineGalleryTableViewCell {
    
    
    
}

// MARK: ------------------------------------ 初始化 ----------------------------------------
extension MineGalleryTableViewCell {
    
    private func initializeUI() {
        selectionStyle = .none
//        contentView.addSubview(collectionView)
//        collectionView.snp.makeConstraints { (make) in
//            make.edges.equalTo(contentView)
//        }
    }
    
}

//// MARK: ------------------------------------ 所有代理 ----------------------------------------
//// MARK: ------------------------------------ UICollectionViewDelegate ----------------------------------------
//extension MineGalleryTableViewCell: UICollectionViewDelegate {
//    
//    func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
//        guard let cell = collectionView.cellForItem(at: indexPath) as? MineGalleryCollectionViewCell else {
//            return
//        }
//        if let delegate = delegate {
//            delegate.galleryTableViewCell?(self, didSelectGalleryCellWithType: cell.status, withIndexPath: indexPath)
//        }
//    }
//    
//}
//
//// MARK: ------------------------------------ UICollectionViewDataSource ----------------------------------------
//extension MineGalleryTableViewCell: UICollectionViewDataSource {
//    
//    func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
//        return 9
//    }
//    
//    func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
//        guard let cell = collectionView.dequeueReusableCell(withReuseIdentifier: String(describing: MineGalleryCollectionViewCell.self), for: indexPath) as? MineGalleryCollectionViewCell else {
//            return collectionView.dequeueReusableCell(withReuseIdentifier: String(describing: MineGalleryCollectionViewCell.self), for: indexPath)
//        }
//        cell.isPortraitTagLabelHidden = indexPath.row != 0
//        if let models = self.models {
//            if models.count == indexPath.row {
//                cell.status = .unselected_highlighted
//                cell.model = nil
//            } else if indexPath.row > models.count {
//                cell.status = .unselected
//                cell.model = nil
//            } else {
//                cell.status = .selected
//                cell.model = models[indexPath.row]
//            }
//        }
//        return cell
//    }
//    
//}
